<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:totoland="http://java.sun.com/jsf/composite/components">
    <h:head>
        <ui:include src="/template/headScript.xhtml"/>

    </h:head>
    <h:body>
        <h:form>
            <p:panel id="REPORT_002" header="#{msg.report_002_header}">

                <p:panel header="#{formReport002Controller.reportTitle}" style="width: 100%;">
                    <p:messages id="REPORT_002msgFrmDetails"></p:messages>
                    <p:panelGrid columns="4" styleClass="frmSelect">
                        <p:outputLabel value="#{msg.label_fiscal_year} :" rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" /> 
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlFiscalYear()}"></f:selectItems>  
                        </p:selectOneMenu>  
                        <p:outputLabel value="เลือกเดือน : " rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlMonth()}"></f:selectItems>
                        </p:selectOneMenu>  
                        <p:outputLabel value="เลือกประเภทรายงานผลการปฏิบัติการ : " rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlReportOperating()}"></f:selectItems> 
                        </p:selectOneMenu>  
                        <p:outputLabel value="เลือกแบบรายงาน : " rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlReportForm()}"></f:selectItems>  
                        </p:selectOneMenu>  
                        <p:outputLabel value="เลือกยุทธศาสตร์ที่ : "/>
                        <p:selectOneMenu style="width: 320px;" id="REPORT_002strategicId" value="#{formReport002Controller.report002.strategicId}" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlStrategic()}"></f:selectItems>
                            <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" update="REPORT_002subStrategicId"/> 
                        </p:selectOneMenu>
                        <p:outputLabel value="เลือกกลยุทธ์ : " />
                        <p:selectOneMenu style="width: 320px;" id="REPORT_002subStrategicId" value="#{formReport002Controller.report002.subStrategicId}" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlSubStrategic(formReport002Controller.report002.strategicId)}"></f:selectItems>
                            <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" update="REPORT_002planId"/>
                        </p:selectOneMenu>
                        <p:outputLabel value="เลือกแผนงาน : "/>
                        <p:selectOneMenu style="width: 320px;" id="REPORT_002planId" value="#{formReport002Controller.report002.planId}" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlPlan(formReport002Controller.report002.subStrategicId)}"></f:selectItems>  
                            <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" update="REPORT_002projectId"/>
                        </p:selectOneMenu>
                        <p:outputLabel value="เลือกโครงการ : " rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" id="REPORT_002projectId"  value="#{formReport002Controller.report002.projectId}" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlProject(formReport002Controller.report002.planId)}"></f:selectItems> 
                            <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" update="REPORT_002Activity"/>
                        </p:selectOneMenu>
                        <p:outputLabel value="เลือกกิจกรรม : " rendered="false"/>
                        <p:selectOneMenu style="width: 320px;" value="#{formReport002Controller.report002.activityId}" rendered="false" disabled="#{formReport002Controller.paramMode=='view'}">  
                            <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                            <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{formReport002Controller.dropdownFactory.ddlActivity()}"></f:selectItems> 
                        </p:selectOneMenu>
                        <p:outputLabel value=""/>
                        <p:outputLabel value=""/>                            
                    </p:panelGrid>

                    <div>
                        <p:panel style="width: 100%;">
                            <f:facet name="header"  class="txtLeft">
                                <p:commandButton value="เพิ่มข้อมูล" oncomplete="REPORT_002dlgAddReportDetail.show()" update="REPORT_002AddReportDetail" actionListener="#{formReport002Controller.initReportDetail()}" rendered="#{formReport010Controller.paramMode!='view'}"/>
                            </f:facet>
                            <p:panelGrid columns="2" styleClass="frmDetail" id="REPORT_002pnlFrm">       

                                <p:dataTable var="item" value="#{formReport002Controller.report002Details}" id="REPORT_002Grid" 
                                             style="width: 1200px"
                                             rowIndexVar="index" editable="true" paginator="true" rows="5" emptyMessage="#{msg.no_data_found}"  
                                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                             rowsPerPageTemplate="5,10,15">  

                                    <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" event="rowEdit" listener="#{formReport002Controller.onEdit}"/>  
                                    <p:ajax onstart="blogui002.show()" oncomplete="blogui002.hide()" event="rowEditCancel" listener="#{formReport002Controller.onCancel}"/>

                                    <p:column headerText="ลำดับ">  
                                        ${index+1}
                                    </p:column>

                                    <p:column headerText="รายละเอียดการดำเนินงาน">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.workDetail}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.workDetail}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="วัตถุประสงค์">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.objective}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.objective}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="เป้าหมาย">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.goalAmount}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.goalAmount}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="ผลการปฏิบัติงาน">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.result}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.result}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="งบประมาณ">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.budget}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.budget}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column headerText="แหล่งที่มางบประมาณ">  
                                        <p:cellEditor>  
                                            <f:facet name="output">  
                                                <h:outputText value="#{item.buggetSource}" />  
                                            </f:facet>
                                            <f:facet name="input">  
                                                <p:inputText value="#{item.buggetSource}" />  
                                            </f:facet>  
                                        </p:cellEditor>
                                    </p:column>

                                    <p:column style="width:6%" rendered="#{formReport002Controller.paramMode!='view'}">  
                                        <p:rowEditor />  
                                    </p:column>
                                    <p:column rendered="#{formReport002Controller.paramMode!='view'}">  
                                        <p:commandLink action="#{formReport002Controller.onDelete(item)}" update="REPORT_002Grid">
                                            <span class="ui-icon ui-icon-trash"></span>
                                            <p:confirm header="#{msg.confirmation_head}" message="#{msg.confirmation_message_delete}" icon="ui-icon-alert" />  
                                        </p:commandLink>
                                    </p:column>

                                </p:dataTable>
                                <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                                    <p:commandButton value="#{msg.yes}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
                                    <p:commandButton value="#{msg.no}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                                </p:confirmDialog>

                            </p:panelGrid>
                        </p:panel>
                    </div>
                    <h:panelGroup id="REPORT_002pnlCmd" rendered="#{formReport002Controller.report002.flowStatusId!=200}">
                        <div align="center">
                            <p:commandButton value="#{msg.btn_save}" actionListener="#{formReport002Controller.save()}" id="REPORT_002btnSave" rendered="#{formReport002Controller.paramMode=='create'}"/>
                            <p:commandButton value="#{msg.btn_edit}" actionListener="#{formReport002Controller.goToEdit()}" id="REPORT_002btnEdit" rendered="#{formReport002Controller.paramMode=='view' 
                                                      and formReport002Controller.canEdit(formReport002Controller.report002.createdUserGroup,formReport002Controller.report002.reportStatus,formReport002Controller.report002.flowStatusId)}"/>
                            <p:commandButton value="#{msg.btn_close}" actionListener="#{formReport002Controller.goToClose()}" id="REPORT_002btnClose" rendered="#{formReport002Controller.paramMode=='view' || formReport002Controller.paramMode=='create'}"/>
                            <p:commandButton value="#{msg.btn_save}" actionListener="#{formReport002Controller.edit()}" id="REPORT_002btnSaveEdit" rendered="#{formReport002Controller.paramMode=='edit'}"/>
                            <p:commandButton value="#{msg.btn_cancel}" id="REPORT_002btnCancel" actionListener="#{formReport002Controller.goToCancel()}" rendered="#{formReport002Controller.paramMode=='edit'}"/>
                        </div>
                    </h:panelGroup>
                </p:panel>

                <p:dialog id="REPORT_002AddReportDetail" header="เพิ่มข้อมูล" widgetVar="REPORT_002dlgAddReportDetail" modal="true" draggable="true">
                    <p:panel style="height:400px;width: 650px;overflow: auto;">
                    <p:messages id="REPORT_002msgAddReportDetail" escape="false" closable="true"></p:messages>
                        <p:panelGrid columns="2" id="REPORT_002pn_addReportDetail">

                            <h:outputLabel value="รายละเอียดการดำเนินงาน *" />  
                            <p:inputTextarea id="REPORT_002lb1" style="width:400px" value="#{formReport002Controller.inputReport002Detail.workDetail}" />  

                            <h:outputLabel value="วัตถุประสงค์ *" />  
                            <p:inputTextarea id="REPORT_002lb2" style="width:400px" value="#{formReport002Controller.inputReport002Detail.objective}" />  

                            <h:outputLabel value="เป้าหมายจำนวน *" />  
                            <p:inputText id="REPORT_002lb3" style="width:400px" value="#{formReport002Controller.inputReport002Detail.goalAmount}" />  

                            <h:outputLabel value="ผลการดำเนินงาน *" />  
                            <p:inputTextarea id="REPORT_002lb4" style="width:400px" value="#{formReport002Controller.inputReport002Detail.result}" />  

                            <h:outputLabel value="งบประมาณ *" />  
                            <p:inputText id="REPORT_002lb6" style="width:400px" value="#{formReport002Controller.inputReport002Detail.budget}" /> 

                            <h:outputLabel value="แหล่งที่มางบประมาณ *" />  
                            <p:inputTextarea id="REPORT_002lb7" style="width:400px" value="#{formReport002Controller.inputReport002Detail.buggetSource}" />

                            <f:facet name="footer">  
                                <p:commandButton value="เพิ่ม" actionListener="#{formReport002Controller.addReportDetail(actionEvent)}" update="REPORT_002msgAddReportDetail,REPORT_002Grid" icon="ui-icon-check" style="margin:0"/>  
                            </f:facet>
                        </p:panelGrid>

                        <style>
                            .ui-panelgrid td {
                                border-color: inherit;
                                border-style: inherit;
                                border-width: 1px;
                                padding: 4px 10px;
                            }
                        </style>
                    </p:panel>
                </p:dialog>
                <p:blockUI  block="REPORT_002" widgetVar="blogui002" trigger="REPORT_002btnSave,REPORT_002btnCancel">
                    LOADING<br />
                    <img src="${request.contextPath}/resources/images/preloader-01.gif"/>
                </p:blockUI>
            </p:panel>
        </h:form>
    </h:body>
</html>